package com.ruoyi.web.controller.ora;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.ora.domain.DeviceConversation;
import com.ruoyi.ora.service.IDeviceConversationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 设备通话记录Controller
 * 
 * @author liuwp
 * @date 2024-11-14
 */
@RestController
@RequestMapping("/ora/device_conversation")
public class DeviceConversationController extends BaseController
{
    @Autowired
    private IDeviceConversationService deviceConversationService;

    /**
     * 查询设备通话记录列表
     */
    @PreAuthorize("@ss.hasPermi('ora:device_conversation:list')")
    @GetMapping("/list")
    public TableDataInfo list(DeviceConversation deviceConversation)
    {
        startPage();
        List<DeviceConversation> list = deviceConversationService.selectDeviceConversationList(deviceConversation);
        return getDataTable(list);
    }

    /**
     * 导出设备通话记录列表
     */
    @PreAuthorize("@ss.hasPermi('ora:device_conversation:export')")
    @Log(title = "设备通话记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DeviceConversation deviceConversation)
    {
        List<DeviceConversation> list = deviceConversationService.selectDeviceConversationList(deviceConversation);
        ExcelUtil<DeviceConversation> util = new ExcelUtil<DeviceConversation>(DeviceConversation.class);
        util.exportExcel(response, list, "设备通话记录数据");
    }

    /**
     * 获取设备通话记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('ora:device_conversation:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(deviceConversationService.selectDeviceConversationById(id));
    }

    /**
     * 新增设备通话记录
     */
    @PreAuthorize("@ss.hasPermi('ora:device_conversation:add')")
    @Log(title = "设备通话记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DeviceConversation deviceConversation)
    {
        return toAjax(deviceConversationService.insertDeviceConversation(deviceConversation));
    }

    /**
     * 修改设备通话记录
     */
    @PreAuthorize("@ss.hasPermi('ora:device_conversation:edit')")
    @Log(title = "设备通话记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DeviceConversation deviceConversation)
    {
        return toAjax(deviceConversationService.updateDeviceConversation(deviceConversation));
    }

    /**
     * 删除设备通话记录
     */
    @PreAuthorize("@ss.hasPermi('ora:device_conversation:remove')")
    @Log(title = "设备通话记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(deviceConversationService.deleteDeviceConversationByIds(ids));
    }
}
